<template>
    <div class="classic-demo">
        <div class="author-demo">
            <div>作者：陈炼</div>
            <div>日期：2017/11/02</div>
        </div>
        <div style="overflow-x: auto;">
            <Table stripe :columns="columns1" :data="data1" style="min-width: 800px;"></Table>
        </div>
        <h3 style="color:#f00">！！！使用场景：纵向列数较少的表格，加最小宽度min-width即可，数值设置为使表格不变形的最小宽度</h3>
        <pre style="background-color: #ececec;">

            <code class="html" v-text="htmlCode">
            </code>
        </pre>
    </div>
</template>
<script>
    import hljs from 'highlight.js'
    export default {
        data () {
            return {
                /*tableWidth: window.innerWidth<=1080?1080:'auto',:width="tableWidth"*/
                columns1: [
                    {
                        title: '姓名',
                        key: 'name'
                    },
                    {
                        title: '年龄',
                        key: 'age'
                    },
                    {
                        title: '地址',
                        key: 'address'
                    }
                ],
                data1: [
                    {
                        name: '王小明',
                        age: 18,
                        address: '北京市朝阳区芍药居'
                    },
                    {
                        name: '张小刚',
                        age: 25,
                        address: '北京市海淀区西二旗'
                    },
                    {
                        name: '李小红',
                        age: 30,
                        address: '上海市浦东新区世纪大道'
                    },
                    {
                        name: '周小伟',
                        age: 26,
                        address: '深圳市南山区深南大道'
                    }
                ],
                htmlCode:'<div style="overflow-x: auto;">\n' +
                '            <Table stripe :columns="columns1" :data="data1" style="min-width: 1080px;"></Table>\n' +
                '        </div>',
            }
        },
        mounted: function () {
            window.setTimeout(function () {
                $('.classic-demo pre code').each(function(i, block) {
                    hljs.highlightBlock(block)
                })
            }, 100)
        },
    }
</script>
